package com.ruoyi.project.jxy.service.impl;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.jxy.domain.SlotEntityRef;
import com.ruoyi.project.jxy.mapper.CorpusMapper;
import com.ruoyi.project.jxy.mapper.SlotEntityRefMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.project.jxy.mapper.IntentionMapper;
import com.ruoyi.project.jxy.domain.Intention;
import com.ruoyi.project.jxy.service.IIntentionService;

import javax.annotation.Resource;

/**
 * 意图Service业务层处理
 *
 * @author ruoyi
 * @date 2019-12-06
 */
@Service
public class IntentionServiceImpl extends ServiceImpl<IntentionMapper, Intention> implements IIntentionService {
    @Resource
    private CorpusMapper corpusMapper;
    @Resource
    private SlotEntityRefMapper slotEntityRefMapper;

    @Override
    public boolean removeIntentionByIds(List<Long> ids) {
        baseMapper.deleteBatchIds(ids);
        for (Long id :
                ids) {
            QueryWrapper wrapper = new QueryWrapper();
            wrapper.eq("intention_id" , id);
            wrapper.eq("create_user" , SecurityUtils.getUsername());
            corpusMapper.delete(wrapper);
            slotEntityRefMapper.delete(wrapper);
        }
        return true;
    }

    @Override
    public List<Intention> checkCorpusByIntentionId(Map map) {

        return baseMapper.checkCorpusByIntentionId(map);

    }

    @Override
    public List<Map> listIntention(Intention intention) {
        return baseMapper.listIntention(intention);
    }

    @Override
    public List<Map> checkNullEntityId(Long id) {
        return baseMapper.checkNullEntityId(id);
    }
}
